<?php 


$db = include ('./db.php');
session_start();

if(isset($_SESSION['username'])){
	echo "<script type='text/javascript'>alert('你已经登录！');</script>";
	// header('location:./index.php');
}



if($_POST){

	$success = 0;

	$user = include ('./user.php');

	foreach ($user as $value) {
		if($value['username'] == $_POST['username'] ){
			
			if($value['passwd']== $_POST['passwd'] ){
				$success = 1;
			}
		}
	}

	if($success==1){
		// echo "<script type='text/javascript'>alert('登录成功！');</script>";

		$_SESSION['username']=$_POST['username'];

		header('location:./index.php');
	}else{
		echo "<script type='text/javascript'>alert('用户或者密码不存在！');</script>";
	}

}








include './template/login.html';


 ?>